<template>
  <EditorComp :init-value="editInfo" @value-change="editChanged"></EditorComp>
  <div v-html="editHtml"> </div>
  <div>
    <el-button type="primary" @click="ajax1">查询帖子列表</el-button>
  </div>
  <div>
    {{ page }}
    <br />
    {{ list }}
  </div>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
const editInfo = ref('<p>初始值</p>')
const editHtml = ref('')

const editChanged = (info: string) => {
  editHtml.value = info
}

import { ApiService } from '../../ts/ApiService'
import { BaseDataResult, BasePageVO, PageBean } from '../../ts/types/BaseResult'
import { TbMessage } from '../../ts/types/TbMessage'
import { ElMessage } from 'element-plus'
import EditorComp from '../../components/EditorComp.vue'

const order = ref(1)
const page = ref({ pageNumber: 1, pageSize: 10 } as PageBean)
const list = ref([] as TbMessage[])

const ajax1 = () => {
  ApiService.get(`/message/${page.value.pageSize}/${page.value.pageNumber}/${order.value}`, { info: '' }, (resp: BaseDataResult<BasePageVO<Array<TbMessage>>>) => {
    if (resp.success) {
      list.value = resp.data.data
      page.value = resp.data.pageBean
    } else {
      ElMessage.error(resp.message)
    }
  })
}
</script>
